﻿using System;
using Microsoft.Xna.Framework.Content;

namespace Firefly.Framework.Windows.ContentReaders
{
    public class FontCollectionContentReader : ContentTypeReader<FontCollection>
    {
        protected override FontCollection Read(ContentReader input, FontCollection existingInstance)
        {
            FontCollection list = new FontCollection();
            int count = input.ReadInt32();

            for (int i = 0; i < count; i++)
            { 
                list.Add(input.ReadString(), input.ReadObject<Font>()); 
            }

            if (!list.ContainsKey("Default"))
            { 
                throw new ApplicationException("A Default font must be specified."); 
            }

            return list;
        }
    }
}
